<!DOCTYPE html>
<!--
  Copyright 2016 Google Inc.

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
-->
<html>
  <head>
    <meta charset="utf-8">
    <title>Checkbox - Material Components Catalog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png">
    <link rel="stylesheet" href="/assets/checkbox.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <script src="/ready.js"></script>
    <style>
      .example--with-js .mdc-form-field {
        min-width: 450px;
      }

      .demo-toggle-group {
        display: inline-block;
      }

      @media (max-width: 600px) {
        .mdc-button {
          margin-bottom: 4px;
        }
      }

      .mdc-button code {
        text-transform: none;
      }
    </style>
  </head>
  <body class="mdc-typography">
    <header class="mdc-toolbar mdc-toolbar--fixed">
      <div class="mdc-toolbar__row">
        <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
          <a href="/" class="catalog-back mdc-toolbar__menu-icon"><i class="material-icons">&#xE5C4;</i></a>
          <span class="mdc-toolbar__title catalog-title">Checkbox</span>
        </section>
      </div>
    </header>
    <main>
      <div class="mdc-toolbar-fixed-adjust"></div>

      <section class="hero">
        <div class="mdc-checkbox">
          <input type="checkbox"
                 id="hero-checkbox"
                 class="mdc-checkbox__native-control"/>
          <div class="mdc-checkbox__background">
            <svg class="mdc-checkbox__checkmark"
                 viewBox="0 0 24 24">
              <path class="mdc-checkbox__checkmark-path"
                    fill="none"
                    d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
            </svg>
            <div class="mdc-checkbox__mixedmark"></div>
          </div>
        </div>
        <label for="hero-checkbox" id="hero-checkbox-label">Checkbox</label>
      </section>

      <section class="example">
        <h2>CSS Only</h2>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox">
              <input type="checkbox"
                     id="basic-checkbox"
                     class="mdc-checkbox__native-control"/>
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="basic-checkbox">Default checkbox</label>
          </div>
          <div class="demo-toggle-group">
            <button type="button" class="mdc-button mdc-button--outlined" onclick="this.parentElement.parentElement.hasAttribute('dir') ? this.parentElement.parentElement.removeAttribute('dir') : this.parentElement.parentElement.setAttribute('dir', 'rtl');">
              Toggle RTL
            </button>
            <button type="button" class="mdc-button mdc-button--outlined" onclick="document.querySelector('.mdc-form-field').classList.toggle('mdc-form-field--align-end');">
              <span>Toggle <code>--align-end</code></span>
            </button>
          </div>
        </div>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox mdc-checkbox--disabled">
              <input type="checkbox"
                     id="basic-disabled-checkbox"
                     class="mdc-checkbox__native-control"
                     disabled />
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="basic-disabled-checkbox">Disabled checkbox</label>
          </div>
          <div>
            <div class="mdc-form-field">
              <div class="mdc-checkbox">
                <input type="checkbox"
                       id="basic-indeterminate-checkbox"
                       class="mdc-checkbox__native-control"/>
                <div class="mdc-checkbox__background">
                  <svg class="mdc-checkbox__checkmark"
                       viewBox="0 0 24 24">
                    <path class="mdc-checkbox__checkmark-path"
                          fill="none"
                          d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                  </svg>
                  <div class="mdc-checkbox__mixedmark"></div>
                </div>
              </div>
              <label for="basic-indeterminate-checkbox">Indeterminate checkbox</label>
            </div>
            <script>
              document.getElementById('basic-indeterminate-checkbox').indeterminate = true;
            </script>
          </div>
          <div>
            <div class="mdc-form-field">
              <div class="mdc-checkbox demo-checkbox--custom-all">
                <input type="checkbox"
                       id="basic-custom-checkbox-all"
                       class="mdc-checkbox__native-control" />
                <div class="mdc-checkbox__background">
                  <svg class="mdc-checkbox__checkmark"
                       viewBox="0 0 24 24">
                    <path class="mdc-checkbox__checkmark-path"
                          fill="none"
                          d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                  </svg>
                  <div class="mdc-checkbox__mixedmark"></div>
                </div>
              </div>
              <label for="basic-custom-checkbox-all">Custom colored checkbox (stroke, fill, ripple, and focus)</label>
            </div>
          </div>
          <div>
            <div class="mdc-form-field">
              <div class="mdc-checkbox demo-checkbox--custom-stroke-and-fill">
                <input type="checkbox"
                       id="basic-custom-checkbox-stroke-and-fill"
                       class="mdc-checkbox__native-control" />
                <div class="mdc-checkbox__background">
                  <svg class="mdc-checkbox__checkmark"
                       viewBox="0 0 24 24">
                    <path class="mdc-checkbox__checkmark-path"
                          fill="none"
                          d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                  </svg>
                  <div class="mdc-checkbox__mixedmark"></div>
                </div>
              </div>
              <label for="basic-custom-checkbox-stroke-and-fill">Custom colored checkbox (stroke and fill only)</label>
            </div>
          </div>
        </div>
      </section>

      <section class="example example--with-js">
        <h2>With JavaScript</h2>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox" data-js>
              <input type="checkbox"
                     id="native-js-checkbox"
                     class="mdc-checkbox__native-control"/>
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="native-js-checkbox">Default checkbox</label>
          </div>
          <div class="demo-toggle-group">
            <button type="button" class="mdc-button mdc-button--outlined toggle-indeterminate"><span>Toggle <code>indeterminate</code></span></button>
            <button type="button" class="mdc-button mdc-button--outlined toggle-disabled"><span>Toggle <code>disabled</code></span></button>
          </div>
        </div>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox" data-js>
              <input type="checkbox"
                     id="native-js-checkbox-indeterminate"
                     class="mdc-checkbox__native-control"
                     checked/>
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="native-js-checkbox-indeterminate">Indeterminate checkbox</label>
          </div>
          <div class="demo-toggle-group">
            <button type="button" class="mdc-button mdc-button--outlined toggle-indeterminate"><span>Toggle <code>indeterminate</code></span></button>
            <button type="button" class="mdc-button mdc-button--outlined toggle-disabled"><span>Toggle <code>disabled</code></span></button>
          </div>
          <script>
            document.getElementById('native-js-checkbox-indeterminate').indeterminate = true;
          </script>
        </div>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox demo-checkbox--custom-all" data-js>
              <input type="checkbox"
                     id="native-js-checkbox-custom-all"
                     class="mdc-checkbox__native-control" />
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="native-js-checkbox-custom-all">Custom colored checkbox (stroke, fill, ripple, and focus)</label>
          </div>
          <div class="demo-toggle-group">
            <button type="button" class="mdc-button mdc-button--outlined toggle-indeterminate"><span>Toggle <code>indeterminate</code></span></button>
            <button type="button" class="mdc-button mdc-button--outlined toggle-disabled"><span>Toggle <code>disabled</code></span></button>
          </div>
        </div>
        <div>
          <div class="mdc-form-field">
            <div class="mdc-checkbox demo-checkbox--custom-stroke-and-fill" data-js>
              <input type="checkbox"
                     id="native-js-checkbox-custom-stroke-and-fill"
                     class="mdc-checkbox__native-control" />
              <div class="mdc-checkbox__background">
                <svg class="mdc-checkbox__checkmark"
                     viewBox="0 0 24 24">
                  <path class="mdc-checkbox__checkmark-path"
                        fill="none"
                        d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
                </svg>
                <div class="mdc-checkbox__mixedmark"></div>
              </div>
            </div>
            <label for="native-js-checkbox-custom-stroke-and-fill">Custom colored checkbox (stroke and fill only)</label>
          </div>
          <div class="demo-toggle-group">
            <button type="button" class="mdc-button mdc-button--outlined toggle-indeterminate"><span>Toggle <code>indeterminate</code></span></button>
            <button type="button" class="mdc-button mdc-button--outlined toggle-disabled"><span>Toggle <code>disabled</code></span></button>
          </div>
        </div>
      </section>
    </main>

    <script src="/assets/material-components-web.js" async></script>
    <script>
      demoReady(function() {
        [].forEach.call(document.querySelectorAll('.mdc-checkbox[data-js]'), function(checkbox) {
          var formField = checkbox.parentElement;
          var formFieldInstance = new mdc.formField.MDCFormField(formField);
          var checkboxInstance = new mdc.checkbox.MDCCheckbox(checkbox);
          formFieldInstance.input = checkboxInstance;

          var row = formField.parentElement;

          var indeterminateToggle = row.querySelector('.toggle-indeterminate');
          if (indeterminateToggle) {
            indeterminateToggle.addEventListener('click', function() {
              checkboxInstance.indeterminate = !checkboxInstance.indeterminate;
            });
          }

          var disabledToggle = row.querySelector('.toggle-disabled');
          if (disabledToggle) {
            disabledToggle.addEventListener('click', function() {
              checkboxInstance.disabled = !checkboxInstance.disabled;
            });
          }
        });
      });
    </script>
  </body>
</html>
